package guiLayer;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

public class DefaultGUI extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JPanel panel = new JPanel();
//	private JPanel panel_1 = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DefaultGUI frame = new DefaultGUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public DefaultGUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1200, 700);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		
		panel.setLayout(null);
		
		
		
		
//		panel = new JPanel();
//		panel.setLayout(null);
//		contentPane.add(panel, BorderLayout.CENTER);
		
	
		
		makeMenuBar();
		
				
		
		
	}
	
	
	
	
	private void productionGUI(){		

		
		panel.removeAll();
		
		ProductionGUI pGUI = new ProductionGUI();		
		JPanel pPanel = pGUI.makeAll();				
		pPanel.setBounds(0, 0, 1100, 600);
		panel.add(pPanel);
		
		
		contentPane.add(panel, BorderLayout.CENTER);
		
		revalidate();
		repaint();
	}
	
	
	
	
	public void storeGUI(){
		panel.removeAll();
		
		StoreGUI sGUI = new StoreGUI();		
		JPanel pPanel = sGUI.makeAll();				
		pPanel.setBounds(0, 0, 1100, 1000);
		panel.add(pPanel);
		
		
		contentPane.add(panel, BorderLayout.CENTER);
		
		revalidate();
		repaint();
	}
	
	
	public void adminGUI(){
		panel.removeAll();
		
		AdminGUI aGUI = new AdminGUI();		
		JPanel pPanel = aGUI.makeAll();				
		pPanel.setBounds(0, 0, 1100, 700);
		panel.add(pPanel);
		
		
		contentPane.add(panel, BorderLayout.CENTER);
		revalidate();
		repaint();
	}
	
	

	
	private void makeMenuBar()
	{
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);

		JMenu fileMenu = new JMenu("File");
		menuBar.add(fileMenu);

		JMenu helpMenu = new JMenu("help");
		menuBar.add(helpMenu);


		
		
		JMenuItem productionItem = new JMenuItem("Produktion");
		productionItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				productionGUI();
//				JOptionPane.showMessageDialog(rootPane, "Hello World");
			}
			
		});
		fileMenu.add(productionItem);
		
		JMenuItem storeItem = new JMenuItem("Lager");
		storeItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				storeGUI();
			}
			
		});
		fileMenu.add(storeItem);
		
		JMenuItem adminItem = new JMenuItem("Admin");
		adminItem.addActionListener(new ActionListener() {
			

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				adminGUI();
			}
		});
		
		fileMenu.add(adminItem);
		
		JMenuItem exitItem = new JMenuItem("close");
		exitItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				setVisible(false);
				dispose();
			}

		});
		fileMenu.add(exitItem);


		JMenuItem aboutItem = new JMenuItem("about");
		aboutItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				JOptionPane.showMessageDialog(rootPane, serialVersionUID, "ABOUT", 3);
			}

		});
		helpMenu.add(aboutItem);


	}
}
